package cn.teduymdj.jxc.controller;


import cn.teduymdj.jxc.myAnnotation.LogAnnotation;
import cn.teduymdj.jxc.pojo.dto.OverflowListAddNewDTO02;
import cn.teduymdj.jxc.pojo.dto.SelectConditionDTO;
import cn.teduymdj.jxc.pojo.entity.Log;
import cn.teduymdj.jxc.pojo.vo.OverflowListGoodsListItemVO;
import cn.teduymdj.jxc.pojo.vo.OverflowListListItemVO;
import cn.teduymdj.jxc.service.OverflowListGoodsService;
import cn.teduymdj.jxc.web.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品报溢商品Controller层
 */
@RestController
@RequestMapping("/overflowListGoods")
public class OverflowListGoodsController {

    @Autowired
    private OverflowListGoodsService overflowListGoodsService;


    /**
     * 保存商品报溢单信息
     *
     * @param overflowListAddNewDTO 商品报溢单信息实体
     * @param overflowListGoodsStr  商品报溢商品信息JSON字符串
     * @return
     */
    //日志保存注解,不用管:李柯辰
    @LogAnnotation(content = "保存商品报溢单信息", type = Log.INSERT_ACTION)

    @RequestMapping("/save")
    public JsonResult<Void> save(OverflowListAddNewDTO02 overflowListAddNewDTO) {

        // 保存商品报溢清单
        overflowListGoodsService.save(overflowListAddNewDTO);

        return JsonResult.ok();
    }

    /**
     * 查询商品报溢单
     *
     * @param sTime 开始时间
     * @param eTime 结束时间
     * @return
     */
    @LogAnnotation(content = "查询商品报溢单", type = Log.SELECT_ACTION)
    @RequestMapping("/list")
    public JsonResult<List<OverflowListListItemVO>> list(@RequestBody SelectConditionDTO selectConditionDTO) {

        List<OverflowListListItemVO> overflowListList = overflowListGoodsService.getOverflowlist(selectConditionDTO);

        return JsonResult.ok(overflowListList);
    }

    /**
     * 查询商品报溢单商品信息
     *
     * @param overflowListId 商品报溢单ID
     * @return
     */
    @LogAnnotation(content = "查询商品报溢单商品信息", type = Log.SELECT_ACTION)
    @RequestMapping("/goodsList")
    public JsonResult<List<OverflowListGoodsListItemVO>> goodsList(Long overflowListId) {


        List<OverflowListGoodsListItemVO> overflowListGoodsList = overflowListGoodsService.getOverflowListGoodsByOverflowListId(overflowListId);


        return JsonResult.ok(overflowListGoodsList);
    }

}
